editor: honor arguments environment variable
authorGiuseppe Scrivano <gscrivan@redhat.com>
Fri, 16 Jan 2015 10:48:50 +0000 (11:48 +0100)
committerColin Walters <walters@verbum.org>
Fri, 16 Jan 2015 14:21:30 +0000 (09:21 -0500)
My EDITOR looks like "EDITOR=emacs -nw", ensure that it is honored.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
src/ostree/ot-editor.c

index e1ca1a185374ef1897af418ef978f235eaa9d2b9..608c58b69ebbca68c4a958291cb192c9290bc00b 100644 (file)
@@ -68,6 +68,7 @@ ot_editor_prompt (OstreeRepo *repo,
   GOutputStream *output;
   const char *editor;
   char *ret = NULL;
+  gs_free gchar *args = NULL;
 
   editor = get_editor ();
   if (editor == NULL)
@@ -86,7 +87,11 @@ ot_editor_prompt (OstreeRepo *repo,
       !g_io_stream_close (G_IO_STREAM (io), cancellable, error))
     goto out;
 
-  ctx = gs_subprocess_context_newv (editor, gs_file_get_path_cached (file), NULL);
+  {
+    gs_free gchar *quoted_file = g_shell_quote (gs_file_get_path_cached (file));
+    args = g_strconcat (editor, " ", quoted_file, NULL);
+  }
+  ctx = gs_subprocess_context_newv ("/bin/sh", "-c", args, NULL);
   gs_subprocess_context_set_stdin_disposition (ctx, GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT);
   gs_subprocess_context_set_stdout_disposition (ctx, GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT);
   gs_subprocess_context_set_stderr_disposition (ctx, GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT);